/* Forgot password box button colours, validation & submission */

$(document).ready(function(){
    var submitbutton = $('input[type="submit"][name="forgotpasswordsubmit"]');
    
    $('form').submit(function(){
        return validatelogin();
    });
    
    submitbutton.mousedown(function(){
        $(this).css('background-color',"#ffd8e0");
    });
    submitbutton.mouseup(function(){
        $(this).css('background-color',"#ffffff");
    });
});

function textboxempty(textbox){
    var trimmedtextbox = $.trim(textbox.val());
    
    if(trimmedtextbox == '')
        return true;
    else
        return false;
}

function highlighttextbox(textbox){
    $(textbox).css('background-color',"#faffbd");
}
function unhighlighttextbox(textbox){
    $(textbox).css('background-color','#ffffff');
}

function validateforgotpassword(){
    var validated = true;
    var textboxes = ['emailbox'];
    
    $.each(textboxes, function(){
        var currtextbox = $('.'+this);
        
        if(textboxempty(currtextbox)){
            highlighttextbox(currtextbox);
            validated = false;
        }
        else
            unhighlighttextbox(currtextbox);
    });
    
    return validated;
}